import path from 'path';

import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
/*import vueDevTools from 'vite-plugin-vue-devtools'*/
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import { VantResolver } from '@vant/auto-import-resolver';

// https://vite.dev/config/
export default defineConfig({
	plugins: [vue()],
	server: {
		proxy: {
			// 选项写法
			'/api': {
				//target: "http://localhost:8089",
				target: 'http://localhost:8099',
				changeOrigin: true,
				rewrite: (path) => path.replace('/api', ''),
			},
		},
	},
	build: {
		sourcemap: false, // 不生成 source map
		terserOptions: {
			compress: {
				// 打包时清除 console 和 debug 相关代码
				drop_console: true,
				drop_debugger: true,
			},
		},
	},
	resolve: {
		alias: {
			'~': path.resolve(__dirname, './'),
			'@': path.resolve(__dirname, './src'),
		},
		extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'],
	},
});
